$("#bnt").on("click", login);
$("#zc").on("click", reg);
let detail;
let url = "http://192.168.1.35:1337";
// 登录
function login() {
    $.post(url + "/api/v1/auth/login", {
        userName: $("#name").val(),
        password: $("#pass").val(),
    }).then((res) => {
        console.log(res.data);
        localStorage.setItem('token', res.data)
        detail = res.data;
        if ($("#name").val() == "" || $("#pass").val() == "") {
            alert("用户名或密码不能为空");
        } else if (res.code == 1) {
            alert('用户名可用');
            location.href = "home.html";

            localStorage.setItem("username", $("#name").val());
        } else {
            alert('用户名或密码错误');
        }
    });
}
// 跳转注册页面
function reg() {
    location.href = "register.html";
}